import { defineStore } from 'pinia'
import { getUserInfo } from "@/api/login";

// 第一个参数是应用程序中 store 的唯一 id
export const usersStore = defineStore('users', {
  state: () => {
    return {
      userInfo: {},
      name: 'user'
    }
  },
  getters: {
    // setUserInfo: (state)=> {

    // }
  },
  actions: {
    async getUserInfos() {
      return new Promise((resolve) => {
        getUserInfo().then(res => {
          if(res) {
            this.userInfo =  res
            resolve(true)
          } else {
            resolve(false)
          }
        })
      })
      
    }
  }
})